package com.jredu.test;

public class TraditionalThreadSynchronized {
	
	public static void main(String[] args){
		
		new TraditionalThreadSynchronized().init();
	}
	
	
	public void init(){
		
		final Outputer outputer = new Outputer();
		//线程1打印：
		new Thread(new Runnable(){
			@Override
			public void run() {
				while(true) {
                    try {
                        Thread.sleep(5);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    outputer.output1("多线程QWERT");
                }
				
			}
		}).start();
		//线程2打印：
		new Thread(new Runnable() {         
            @Override
            public void run() {
                while(true) {
                    try {
                        Thread.sleep(5);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    outputer.output1("2ASDF");
                }

            }
        }).start();
		
	}
	
	
	static class Outputer {
        //自定义一个字符串打印方法，一个个字符的打印
        public void output1(String name) {
            int len = name.length();
            for(int i = 0; i < len; i++) {
                System.out.print(name.charAt(i));
            }
            System.out.println("- - -");     
        }       
    }

}
